﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace Natty.NetCore.SqlSuger
{
    public class BaseSqlClient : SqlSugar
    {
        public BaseSqlClient() : base()
        {

        }
        public void CreateTable()
        {
            foreach (var item in db.DbMaintenance.GetTableInfoList())
            {
                string entityName = item.Name;
                db.MappingTables.Add(entityName, item.Name);
                foreach (var col in db.DbMaintenance.GetColumnInfosByTableName(item.Name))
                {
                    db.MappingColumns.Add(col.DbColumnName, col.DbColumnName, entityName);
                }
            }
            var path = System.AppDomain.CurrentDomain.BaseDirectory.Replace(@"Natty.NetCore.SqlSuger.UnitTest\bin\Debug\netcoreapp3.1\", @"Natty.NetCore.Models");
            db.DbFirst.IsCreateAttribute().CreateClassFile(path, "Natty.NetCore.Models");

        }
    }
}
